#include "node_content_base.h"


NodeContentBase::NodeContentBase(QWidget *parent) : QWidget(parent)
{
    layout = new QVBoxLayout();
    this->layout->setContentsMargins(0,0,0,0);
    this->setLayout(this->layout);
}


NodeContentNumber::NodeContentNumber(QWidget *parent) : NodeContentBase(parent)
{
    //this->layout->addWidget(edit);
    //border-width: 1px;
    edit->setStyleSheet("QLineEdit { background: gray; border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignRight);

}

double NodeContentNumber::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentNumber::SetData(QString text)
{
    this->edit->setText(text);
}

NumberData NodeContentNumber::GetNumberData()
{
    NumberData data;
    data.data[0] = this->edit->text().toDouble();
    data.data_length = 1;
    return data;
}

void NodeContentNumber::SetNumberData(NumberData data)
{
    QString text = QString::number(data.data[0],10,4);
    this->edit->setText(text);
}

NodeContentOutput::NodeContentOutput(QWidget *parent) : NodeContentBase(parent)
{

    //this->layout->addWidget(edit);
    //border-width: 1px;
    edit->setStyleSheet("QLabel { border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignLeft);

}

NumberData NodeContentOutput::GetNumberData()
{
    NumberData data;
    data.data[0] = this->edit->text().toDouble();
    data.data_length = 1;
    return data;
}

void NodeContentOutput::SetNumberData(NumberData data)
{
    QString text = QString::number(data.data[0],10,4);
    this->edit->setText(text);
}

double NodeContentOutput::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentOutput::SetData(QString text)
{
    this->edit->setText(text);
}

NodeContentAdd::NodeContentAdd(QWidget *parent) : NodeContentBase(parent)
{

    //border-width: 1px;
    edit->setStyleSheet("QLabel { border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignLeft);

}

NumberData NodeContentAdd::GetNumberData()
{
    NumberData out;
    out.data[0] = data.data[0] + data.data[1];
    out.data_length = 1;
    return out;
}

void NodeContentAdd::SetNumberData(NumberData data)
{
    this->data = data;
}

double NodeContentAdd::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentAdd::SetData(QString text)
{
    this->edit->setText(text);
}

/////
NodeContentSub::NodeContentSub(QWidget *parent) : NodeContentBase(parent)
{

    //border-width: 1px;
    edit->setStyleSheet("QLabel { border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignLeft);

}

NumberData NodeContentSub::GetNumberData()
{
    NumberData out;
    out.data[0] = data.data[0] - data.data[1];
    out.data_length = 1;
    return out;
}

void NodeContentSub::SetNumberData(NumberData data)
{
    this->data = data;
}

double NodeContentSub::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentSub::SetData(QString text)
{
    this->edit->setText(text);
}

///////
NodeContentMul::NodeContentMul(QWidget *parent) : NodeContentBase(parent)
{

    //border-width: 1px;
    edit->setStyleSheet("QLabel { border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignLeft);

}

NumberData NodeContentMul::GetNumberData()
{
    NumberData out;
    out.data[0] = data.data[0] * data.data[1];
    out.data_length = 1;
    return out;
}

void NodeContentMul::SetNumberData(NumberData data)
{
    this->data = data;
}

double NodeContentMul::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentMul::SetData(QString text)
{
    this->edit->setText(text);
}


///////////
NodeContentDiv::NodeContentDiv(QWidget *parent) : NodeContentBase(parent)
{

    //border-width: 1px;
    edit->setStyleSheet("QLabel { border-radius:5px;font-size:20px; }");
    edit->setAlignment(Qt::AlignLeft);

}

NumberData NodeContentDiv::GetNumberData()
{
    NumberData out;
    out.data[0] = data.data[0] / data.data[1];
    out.data_length = 1;
    return out;
}

void NodeContentDiv::SetNumberData(NumberData data)
{
    this->data = data;
}

double NodeContentDiv::GetData()
{
    return this->edit->text().toDouble();
}

void NodeContentDiv::SetData(QString text)
{
    this->edit->setText(text);
}
